<?php

class IndexAction extends SaleAction
{
    public function index()
    {

        $this->display();
    }
    public function clear()
    {
        $this->cache_clear();
        $this->display();

    }


    public function head()
    {
     //   dump($_SESSION);exit();
        $myinfo=I('session.my_info');
        $username=$myinfo["username"];
        $realname=$myinfo["name"];
        $role=$myinfo["role"];
        $rolemodel=M("role");
        $roledata=$rolemodel->find($role);
        $this->username=$username;
        $this->realname=$realname;
        $this->role=$roledata["name"];

        $this->display();
    }

    public function foot()
    {

        $this->display();
    }

    public function left()
    {

        // dump($_SESSION);exit();
        $role = M("role");

        $roleid = I("session.roleid", 0);
        $rolecon["id"] = $roleid;
        if (empty($roleid)) $this->error("角色为空");
        $data = $role->field("menu")->where($rolecon)->find();
        $rolemenu = $data["menu"];
        $this->rolemenu = $rolemenu;

        //dump(I("session.department"));
        //dump($_SESSION); exit;

        $admin = I("session.admin", 0);
        $this->admin = $admin;
        $temp=$this->getMymenu();
        $this->mymenu=$temp;
        //    echo $this->rolemenu;
        $this->display();
    }

    public  function  getMymenu()
    {
        $datas="";
        $roleid = I("session.roleid", 0);
        if ($roleid == 14)
        {
            $url = U('Custom/index', array('level' => 3));
            $datas.= '<li><a href="' . $url . '" target="frmright" p="0">回访客户</a></li>';
        }
        return $datas;
    }

    public function main()
    {
        $roleid = I("session.roleid", 0);


        $empids = $this->getMyEmployee();
        $condition['adduser'] = array('in', $empids);
        $condition['apptime'] = array('egt', date("Y-m-d"));
        $data=$this->getPageData('AppointView',0,$condition);
       // dump($data);exit;
        if($data["list"]!=null)
        {
            $this->redirect("Appointment/index");
        }


        if (!empty($roleid))
        {
            $role = M("role");
            $condition["id"] = $roleid;
            $roledata = $role->field("firstpage")->where($condition)->find();
            $firstpage = $roledata["firstpage"];
            if ($firstpage) $this->redirect($firstpage);
            $this->display();
        }

    }

    public function  logout()
    {
        session_destroy();
        redirect( __APP__ ,0,"退出成功");

    }

    public function  weclome()
    {
        $message = new messageAction();
        $data = $message->inboxData();
        $this->list = $data;
        $this->display();
    }

    public function  _empty()
    {
        echo "there is no this function";
    }
}